package dat255.calendarclock.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.LinearLayout;
import dat255.calendarclock.model.event.SubEvent;

/**
 * An item in a list
 * 
 * @author Marcus Hultman, Gabriel Andersson
 *
 */
public class ListItem extends LinearLayout{
	private static final int height = 75;
	private String name, time;
	private SubEvent sE;
	
	public ListItem(Context context, AttributeSet attrs, String name, String time, SubEvent sE) {
		super(context, attrs);
		setWillNotDraw(false);
		
		this.name=name;
		this.time=time;
		this.sE=sE;
	}
	
	/**
	 * 
	 * @return the subEvent in the item
	 */
	public SubEvent getSubEvent(){
		return sE;
	}	
	
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(getWidth(), height);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Log.d("debug", "w: "+getWidth());
		Paint paint = new Paint();
		paint.setColor(Color.CYAN);
		canvas.drawRect(new Rect(0, 0, getWidth(), height), paint);
		canvas.drawCircle(10, height/2, 2, paint);
		canvas.drawText(name, getWidth(), height/2, paint);
		paint.setTextSize(0.5f);
		canvas.drawText(time, 25, height/2, paint);
		
		
	}


}
